<template>
  <div class="custome-table">
    <el-form :disabled="detail">
      <div class="table-title">水污染源在线监测仪器参数设置记录表</div>
      <div class="custom-table">
        <table class="w20">
          <tr class="hide">
            <td /><td /><td /><td /><td /><td /><td /><td /><td /><td /><td /><td /><td /><td /><td /><td /><td /><td /><td /><td />
          </tr>
          <tr>
            <td colspan="3">仪器名称</td>
            <td colspan="14"><el-input v-model="form.key1" /></td>
            <td colspan="3">&nbsp;</td>
          </tr>
          <tr>
            <td colspan="3">测量原理</td>
            <td colspan="14"><el-input v-model="form.key2" /></td>
            <td colspan="3">&nbsp;</td>
          </tr>
          <tr>
            <td colspan="3">分析方法</td>
            <td colspan="14"><el-input v-model="form.key3" /></td>
            <td colspan="3">&nbsp;</td>
          </tr>
          <tr>
            <td class="center" colspan="3">参数类型</td>
            <td class="center" colspan="5">参数名称</td>
            <td class="center" colspan="3">原始值</td>
            <td class="center" colspan="3">修改值</td>
            <td class="center" colspan="3">修改原因</td>
            <td class="center" colspan="3">修改日期</td>
          </tr>
          <template v-for="(arr,i) in tableLabels">
            <template v-for="(label,j) in arr[1]">
              <tr v-if="j==0" :key="i+'_'+j">
                <td class="center" colspan="3" :rowspan="arr[1].length">{{ arr[0] }}</td>
                <td colspan="5">{{ label }}</td>
                <td colspan="3">
                  <el-input v-model="form['key'+(3+arr[2]*4+1)]" />
                  <!-- {{ (3+arr[2]*4+1) }} -->
                </td>
                <td colspan="3"><el-input v-model="form['key'+(3+arr[2]*4+2)]" /></td>
                <td colspan="3"><el-input v-model="form['key'+(3+arr[2]*4+3)]" /></td>
                <td class="date w100" colspan="3"><el-date-picker v-model="form['key'+(3+arr[2]*4+4)]" type="date" value-format="yyyy-MM-dd" /></td>
              </tr>
              <tr v-else :key="i+'_'+j">
                <td colspan="5">{{ label }}</td>
                <td colspan="3">
                  <el-input v-model="form['key'+(3+arr[2]*4+j*4+1)]" />
                  <!-- {{ (3+arr[2]*4+j*4+4) }} -->
                </td>
                <td colspan="3"><el-input v-model="form['key'+(3+arr[2]*4+j*4+2)]" /></td>
                <td colspan="3"><el-input v-model="form['key'+(3+arr[2]*4+j*4+3)]" /></td>
                <td class="date w100" colspan="3"><el-date-picker v-model="form['key'+(3+arr[2]*4+j*4+4)]" type="date" value-format="yyyy-MM-dd" /></td>
              </tr>
            </template>
          </template>
          <tr>
            <td colspan="3" class="text-center">说明</td>
            <td colspan="17"><el-input v-model="form.key232" :rows="5" type="textarea" /></td>
          </tr>
        </table>
        <table style="margin-top: 20px;">
          <tr>
            <td width="150">上传文件：图片</td>
            <td colspan="6"><TableUpLoadFile ref="tableUploadFile" :files-list="filePath" :detail="detail" /></td>
          </tr>
          <tr>
            <td width="150">上传文件：视频</td>
            <td colspan="6"><TableUpLoadVideo ref="tableUploadVideo" :video-list="videoPath" :detail="detail" /></td>
          </tr></table>
      </div>
    </el-form>

  </div>
</template>

<script>
import { getDict } from '@/utils/dict'
import { fileUrl, staticImgUrl } from '@/url'
import TableUpLoadFile from './../TableUpLoadFile'
import TableUpLoadVideo from './../TableUpLoadVideo'
export default {
  name: 'Xj',
  components: {
    TableUpLoadFile,
    TableUpLoadVideo
  },
  props: {
    obj: {
      type: Object,
      default: null
    },
    maintenaIndex: {
      type: Number,
      default: 0
    },
    detail: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      imagePreview: false,
      videoLoadingFlag: false,
      imgLoadingFlag: false,
      typeList: [],
      fileUrl, staticImgUrl,
      yesNoList: [
        { value: '是', label: '是' },
        { value: '否', label: '否' }
      ],
      // 显示的图片数据
      filePath: [],
      showVideoPath: [],
      videoPath: [],
      form: {
        key0:'', key1:'', key2:'', key3:'', key4:'', key5:'', key6:'', key7:'', key8:'', key9:'', key10:'', key11:'', key12:'', key13:'', key14:'', key15:'', key16:'', key17:'', key18:'', key19:'', key20:'', key21:'', key22:'', key23:'', key24:'', key25:'', key26:'', key27:'', key28:'', key29:'', key30:'', key31:'', key32:'', key33:'', key34:'', key35:'', key36:'', key37:'', key38:'', key39:'', key40:'', key41:'', key42:'', key43:'', key44:'', key45:'', key46:'', key47:'', key48:'', key49:'', key50:'', key51:'', key52:'', key53:'', key54:'', key55:'', key56:'', key57:'', key58:'', key59:'', key60:'', key61:'', key62:'', key63:'', key64:'', key65:'', key66:'', key67:'', key68:'', key69:'', key70:'', key71:'', key72:'', key73:'', key74:'', key75:'', key76:'', key77:'', key78:'', key79:'', key80:'', key81:'', key82:'', key83:'', key84:'', key85:'', key86:'', key87:'', key88:'', key89:'', key90:'', key91:'', key92:'', key93:'', key94:'', key95:'', key96:'', key97:'', key98:'', key99:'', key100:'', key101:'', key102:'', key103:'', key104:'', key105:'', key106:'', key107:'', key108:'', key109:'', key110:'', key111:'', key112:'', key113:'', key114:'', key115:'', key116:'', key117:'', key118:'', key119:'', key120:'', key121:'', key122:'', key123:'', key124:'', key125:'', key126:'', key127:'', key128:'', key129:'', key130:'', key131:'', key132:'', key133:'', key134:'', key135:'', key136:'', key137:'', key138:'', key139:'', key140:'', key141:'', key142:'', key143:'', key144:'', key145:'', key146:'', key147:'', key148:'', key149:'', key150:'', key151:'', key152:'', key153:'', key154:'', key155:'', key156:'', key157:'', key158:'', key159:'', key160:'', key161:'', key162:'', key163:'', key164:'', key165:'', key166:'', key167:'', key168:'', key169:'', key170:'', key171:'', key172:'', key173:'', key174:'', key175:'', key176:'', key177:'', key178:'', key179:'', key180:'', key181:'', key182:'', key183:'', key184:'', key185:'', key186:'', key187:'', key188:'', key189:'', key190:'', key191:'', key192:'', key193:'', key194:'', key195:'', key196:'', key197:'', key198:'', key199:'', key200:'', key201:'', key202:'', key203:'', key204:'', key205:'', key206:'', key207:'', key208:'', key209:'', key210:'', key211:'', key212:'', key213:'', key214:'', key215:'', key216:'', key217:'', key218:'', key219:'', key220:'', key221:'', key222:'', key223:'', key224:'', key225:'', key226:'', key227:'', key228:'', key229:'', key230:'', key231:'', key232:'', key233:'', key234:'', key235:'', key236:'', key237:'', key238:'', key239:'', key240:'', key241:'', key242:'', key243:'', key244:'', key245:'', key246:'', key247:'', key248:'', key249:''

      },
      tableLabels: [
        ['工作曲线', ['测量量程', '工作曲线斜率k', '工作曲线截距b'], 0], // 3
        ['消解条件', ['消解温度（°C）', '消解时间（min）', '消解压力（kPa）'], 3], // 6
        ['冷却条件', ['冷却温度（°C）', '冷却时间（min）'], 6], // 8
        ['显色条件', ['显色温度（°C）', '显色时间（min）'], 8], // 10
        ['测定单元', ['光度计波长（nm）', '光度计零点信号值', '光度计量程信号值', '滴定溶液浓度（mg/L）', '滴定终点判定方式', '电极响应时间（s）', '电极测量时间（s）'], 10], // 17
        ['分析试样', ['蠕动泵管管径（mm）', '蠕动泵进样时间（s）', '标样核查浓度（mg/L）', '注射泵单次体积（mL）', '注射泵次数（次）'], 17], // 23
        ['试剂（1）', ['泵管管径（mm）', '进样时间（s）', '单次体积（mL）', '次数（次）'], 23], // 27
        ['试剂（2）', ['泵管管径（mm）', '进样时间（s）', '单次体积（mL）', '次数（次）'], 27], // 31
        ['试剂（3）', ['泵管管径（mm）', '进样时间（s）', '单次体积（mL）', '次数（次）'], 31], // 35
        ['试剂（4）', ['泵管管径（mm）', '进样时间（s）', '单次体积（mL）', '次数（次）'], 35], // 39
        ['试剂（5）', ['泵管管径（mm）', '进样时间（s）', '单次体积（mL）', '次数（次）'], 39], // 43
        ['测定单元', ['电极信号'], 44], // 45
        ['校正液', ['零点校正液浓度（mg/L）', '量程校正液浓度（mg/L）'], 45], // 47
        ['报警限值', ['报警上限（mg/L)', '报警下限（mg/L)'], 47], // 49
        ['明渠流量', ['堰槽型号', '测量量程', '流量公式'], 49], // 52
        ['测量间隔', ['- -'], 52], // 53
        ['水质自动采样系统', ['流量等比例采样设定', '时间等比例采样设定', '留样保存温度'], 53], // 56
        ['测量间隔', ['- -'], 56] // 57
      ]

    }
  },
  mounted() {
    this.init()
    this.typeList = getDict('e015')
    // const infoStr = this.$store.getters.user.info
    // if (infoStr) {
    //   const info = JSON.parse(infoStr)
    //   this.form.key6 = info.realName
    // }
  },
  methods: {
    init() {
      if (this.obj.list) {
        const maintenaData = this.obj.list[this.maintenaIndex]
        if (maintenaData.filePath) {
          this.filePath = JSON.parse(maintenaData.filePath)
          this.$refs['tableUploadFile'].init(this.filePath)
        }
        if (maintenaData.videoPath) {
          this.videoPath = JSON.parse(maintenaData.videoPath)
        }
        if (maintenaData.formContent) {
          this.form = JSON.parse(maintenaData.formContent)
        }
        this.form.enterpriseName = this.obj.enterpriseName
        this.form.outletName = this.obj.outletName
      }
      if (this.obj.lastMaintenance) {
        var lastMaintenance = JSON.parse(this.obj.lastMaintenance.formContent)
        this.form.key1 = lastMaintenance.key1
        this.form.key2 = lastMaintenance.key2
        this.form.key3 = lastMaintenance.key3
      }
    },
    getFormData() {
      return {
        formContent: JSON.stringify(this.form),
        filePath: this.$refs.tableUploadFile ? this.$refs.tableUploadFile.getPaths() : [],
        videoPath: this.$refs.tableUploadVideo ? this.$refs.tableUploadVideo.getPaths() : [],
        maintenaIndex: this.maintenaIndex
      }
    },
    clearData() {
      this.form = {
      }
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
